{layout name="main"/}
<div class="wrapper wrapper-content animated fadeInUp">
  {include file="return"/}
    <div class="row">
    <div class="col-sm-12">
    <div class="ibox">

    <div class="ibox-title">
    <h5>修改 旗舰店</h5>

    </div>
    <div class="ibox-content">
    <form method="post" action="" class="form-horizontal m-t" id="cz">
    <div class="form-group">
    <label class="col-sm-3 control-label" >名称 <span class="text-danger">*</span> </label>
    <div class="col-sm-5">
    <input type="text" placeholder="请输入名称"  class="form-control" name="mall_name" value="{$mallname.mall_name}">
    </div>
    </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">副名称 <span class="text-danger">*</span> </label>
            <div class="col-sm-5">
                <input type="text" placeholder="请输入副名称"  class="form-control" name="sub_name" value="{$mallname.sub_name}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">图片上传<span class="text-danger">*</span></label>
            <div class="col-sm-5">
            	{:widget('Upload/image/',[['name'=>'mall_img','value'=>$mallname.mall_img]])}
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 推荐尺寸：240px*240px</span>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">链接地址 <span class="text-danger">*</span> </label>
            <div class="col-sm-5">
                <input type="text" placeholder="请输入链接地址"  class="form-control" name="mall_url" value="{$mallname.mall_url}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">排序 <span class="text-danger">*</span> </label>
            <div class="col-sm-1">
                <input type="text" placeholder=""  class="form-control" name="sort_order" value="{$mallname.sort_order}">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">是否推荐 <span class="text-danger">*</span> </label>
            <div class="col-sm-5">
                <div class="radio radio-info radio-inline">
                    
                    <input type="radio" id="inlineRadio1" value="1" name="is_rec" {if condition="$mallname.is_rec eq 1"}checked{/if}>
                    
                    <label for="inlineRadio1"> 推荐 </label>
                </div>

                <div class="radio radio-info radio-inline">
                   
                    <input type="radio" id="inlineRadio1" value="0" name="is_rec" {if condition="$mallname.is_rec eq 0"}checked{/if}>
                    
                    <label for="inlineRadio2"> 不推荐 </label>
                </div>
            </div>
        </div>


    <div class="form-group">
    <div class="col-sm-4 col-sm-offset-3">
    	<input type="hidden" name="mall_id" value="{$mallname.mall_id}"/>
    <button class="btn btn-primary"  type="button"  onclick='add()'>确认提交</button>
    </div>
    </div>

    </form>
    </div>
    </div>
    </div>
    </div>
</div>

<script type="text/javascript">

    var BASE_URL = 'js/plugins/webuploader/index.html';

    // 初始化Web Uploader
    var uploader = WebUploader.create({

        // 选完文件后，是否自动上传。
        auto: false,

        // swf文件路径
        swf: BASE_URL + '/js/Uploader.swf',

        // 文件接收服务端。
        server: '#',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker'


    });

    // 当有文件添加进来的时候
    uploader.on( 'fileQueued', function( file ) {

        if(file.ext=="jpg" || file.ext=="png"){

            //创建缩略图
            uploader.makeThumb( file, function( error, src ) {
                if ( !error ) {
                        $("#pic").show().attr("href",src);
                }
            },240,240);

        }else{
            swal("错误", "请上传图片格式如JPG,PNG", "error");
            return;
        }

    });
    
//  2016 12 5  刘景能
	function add()
	{
        var articledata = $("#cz").serialize();
        post({
            url: "{:url('/admin/Mall/editlist')}",
            data: articledata,
            success: function (res) {
                swal({
                      title: '成功',
                      text: res.message,
                      type: "success"
                   }, function () {
                       window.location.href="/index.php/admin/Mall/showList.html"; 
                    }); 
            },
            error: function (error){
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
           
        });

    }

    
    
</script>